#include<bits/stdc++.h>
using namespace std;
class TravelVIP
{
    protected:
        int vipID,point;
    public:
        TravelVIP(){}
        TravelVIP(int _id,int _po=0)
        {
            vipID=_id;
            point=_po;
        }
};
class admitCard
{
    protected:
        int cardID,limit,cardPoint;
        float money;
        string name;
    public:
        admitCard(){ }
        admitCard(int _id,int _li,string _na,int cp=0,float mo=0)
        {
            cardID=_id;
            limit=_li;
            cardPoint=cp;
            money=mo;
            name=_na;
        }
};
class travelCard:public TravelVIP,public admitCard
{
    public:
        travelCard(int _id,int _id1,int _li,string _na,int _po=0,int cp=0,float mo=0):TravelVIP(_id,_po),admitCard(_id1,_li,_na,cp,mo)
        {}
        void book(double m)
        {
            if(m>limit)
                return;//超额度不操作
            limit-=m;
            money+=m;
            point+=m;
            cardPoint+=m;
        }
        void spend(double m)
        {
            if(m>limit)
                return;//超额度不操作
            limit-=m;
            money+=m;
            cardPoint+=int(m);
        }
        void back(double m)
        {
            money-=m;
            cardPoint-=int(m);
        }
        void change(double m)
        {
            cardPoint-=int(m);
            point+=int(m/2);
        }
        void display()
        {
            cout<<vipID<<" "<<point<<"\n";
            cout<<cardID<<" "<<name<<" "<<money<<" "<<cardPoint<<"\n";
        }
};
int main()
{
    int _id,_id1,_li;
    string _na;
    cin>>_id>>_id1>>_na>>_li;
    travelCard ans(_id,_id1,_li,_na);
    int n;
    cin>>n;
    while(n--)
    {
        char tmp;
        cin>>tmp;
        double num;
        cin>>num;
        if(tmp=='o')
        {
            ans.book(num);
        }
        else if(tmp=='c')
        {
            ans.spend(num);
        }
        else if(tmp=='q')
        {
            ans.back(num);
        }
        else if(tmp=='t')
        {
            ans.change(num);
        }
    }
    ans.display();
}